<?php

namespace Trois\MainServerRegister\Registers;

use EasySwoole\Component\Singleton;
use EasySwoole\EasySwoole\Swoole\EventRegister;
use Trois\Design\Observer\IObserver;
use EasySwoole\Component\Di;
use EasySwoole\Component\Process\Manager;
use Trois\Process\CheckMiniProcess;

class ProcessRegister extends BaseRegister implements IObserver
{

    use Singleton;

    private array $process;

    private function __construct(EventRegister $register)
    {
        //不需要初始化传参的进程
        $this->process = [
//            CheckMiniProcess::getInstance(),
        ];

        parent::__construct($register);

    }

    public function update()
    {
        $this->init();
    }

    protected function init()
    {
        foreach ($this->process as $process) {
            Di::getInstance()->set($process->getProcessName(), $process->getProcess());
            Manager::getInstance()->addProcess($process);
        }
    }


}